package com.hongxun.design.jungong.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.hongxun.design.R;
import com.hongxun.design.sqlite.bean.OldBj;

import java.util.List;

/**
 * Created by Administrator on 2017/8/3.
 */

public class Adapter_OldBj extends myBaseAdapter<OldBj> {

    public Adapter_OldBj(Activity activity, List<OldBj> list) {
        super(activity, list);
    }

    @Override
    public View getV(int position, View convertView, OldBj obj) {
        ViewHolder holder;
        if (null == convertView) {
            convertView = inflater.inflate(R.layout.oldbj_listview_item, null);
            holder = new ViewHolder(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.setData(obj);
        return convertView;
    }

    class ViewHolder {
        private TextView tv1, tv2;

        ViewHolder(View convertView) {
            findViewByID(convertView);
            convertView.setTag(this);
        }

        private void findViewByID(View view) {
            tv1= (TextView) view.findViewById(R.id.tv1);
            tv2= (TextView) view.findViewById(R.id.tv2);
        }

        public void setData(OldBj obj) {
            tv1.setText(obj.getName());
            tv2.setText(obj.getCode());
        }
    }
}
